package com.mine.modules.vm.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mine.common.domain.vo.Result;
import com.mine.modules.sys.domain.dto.RoleDto;
import com.mine.modules.vm.domain.dto.*;
import com.mine.modules.vm.domain.query.AssetsPageQuery;
import com.mine.modules.vm.domain.query.CountElementQuery;
import com.mine.modules.vm.domain.query.ElementPageQuery;
import com.mine.modules.vm.domain.query.LayerQuery;
import com.mine.modules.vm.entity.VmAssets;
import com.mine.modules.vm.service.IVmLayerElementService;
import com.mine.modules.vm.service.IVmLayerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 场景图层管理
 * </p>
 *
 * @author author
 * @since 2024-10-15
 */
@Slf4j
@Api(tags = "图元管理")
@RestController
@RequestMapping("/vm/layer/element")
@RequiredArgsConstructor
public class VmLayerElementController {

    private final IVmLayerElementService vmLayerElementService;

    @ApiOperation(value = "分页获取图元列表", notes = "分页获取图元列表")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public Result<?> queryPageList(ElementPageQuery elementPageQuery) {
        return vmLayerElementService.queryPageList(elementPageQuery);
    }

    @ApiOperation("添加或修改图元")
    @PostMapping(value = "/addOrEdit")
    public Result<?> addOrEdit(AddElementDto addElementDto) {
        return vmLayerElementService.addOrEdit(addElementDto);
    }

    @ApiOperation(value="删除图元", notes="删除图元")
    @RequestMapping(value = "/delete", method = {RequestMethod.GET})
    public Result<?> delete(@RequestParam String id) {
        return vmLayerElementService.delete(id);
    }

    @ApiOperation(value="批量删除图元", notes="批量删除图元")
    @RequestMapping(value = "/deleteBatch", method = {RequestMethod.GET})
    public Result<?> deleteBatch(@RequestParam String ids) {
        return vmLayerElementService.deleteBatch(ids);
    }

    @ApiOperation(value = "绑定图元场景图层id", notes = "绑定图元场景图层id")
    @RequestMapping(value = "/bindSceneLayerOfElement", method = {RequestMethod.POST})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "sId", value = "图元主键id",required = true),
            @ApiImplicitParam(name = "sceneLayerId", value = "场景图层id",required = true)
    })
    public Result<?> bindSceneLayerOfElement(@RequestParam String sId, @RequestParam(required = false) String sceneLayerId) {
        return vmLayerElementService.bindSceneLayerOfElement(sId, sceneLayerId);
    }

    @ApiOperation(value = "清除图元场景图层id", notes = "清除图元场景图层id")
    @RequestMapping(value = "/cleanSceneLayerOfElement", method = {RequestMethod.POST})
    @ApiImplicitParam(name = "sId", value = "图元主键id",required = true)
    public Result<?> cleanSceneLayerOfElement(@RequestParam String sId) {
        return vmLayerElementService.cleanSceneLayerOfElement(sId);
    }

    @ApiOperation("通过场景图元id查询传感器列表")
    @RequestMapping(value = "/getSensorBySceneLayerId", method = RequestMethod.GET)
    public Result<?> getSensorBySceneLayerId(@RequestParam  String sceneLayerId) {
        return vmLayerElementService.getSensorBySceneLayerId(sceneLayerId);
    }

    @ApiOperation("获取详情")
    @RequestMapping(value = "/getDetailsId", method = RequestMethod.GET)
    public Result<?> getDetailsId(@RequestParam  String id) {
        return vmLayerElementService.getDetailsId(id);
    }

    @ApiOperation("通过场景图层Id获取详情")
    @RequestMapping(value = "/getDetailsBySceneLayerId", method = RequestMethod.GET)
    public Result<?> getDetailsBySceneLayerId(@RequestParam  String sceneLayerId) {
        return vmLayerElementService.getDetailsBySceneLayerId(sceneLayerId);
    }

}
